import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 零件号信息 */
export interface PartList {
  id: number // id
  partNumber: string // 零件号
  supplyCode: string // 供应商代码
  supplyName: string // 供应商名称
  partDes: string // 零件描述
}

// 零件号 API
export const PartListApi = {
  // 查询零件号分页
  getPartListPage: async (params: any) => {
    return await request.get({ url: `/business/part-list/page`, params })
  },

  // 查询零件号详情
  getPartList: async (id: number) => {
    return await request.get({ url: `/business/part-list/get?id=` + id })
  },

  // 新增零件号
  createPartList: async (data: PartList) => {
    return await request.post({ url: `/business/part-list/create`, data })
  },

  // 修改零件号
  updatePartList: async (data: PartList) => {
    return await request.put({ url: `/business/part-list/update`, data })
  },

  // 删除零件号
  deletePartList: async (id: number) => {
    return await request.delete({ url: `/business/part-list/delete?id=` + id })
  },

  /** 批量删除零件号 */
  deletePartListList: async (ids: number[]) => {
    return await request.delete({ url: `/business/part-list/delete-list?ids=${ids.join(',')}` })
  },

  // 导出零件号 Excel
  exportPartList: async (params) => {
    return await request.download({ url: `/business/part-list/export-excel`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/business/part-list/get-import-template' })
  }
}
